/*
 * Created by JFormDesigner on Wed Jun 26 20:05:52 CST 2024
 */

package scct.zhanghongbo.ui;

import scct.zhanghongbo.model.Staff;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/**
 * @author 84160
 */
public class FormMain extends JFrame {
    public static FormMain MAIN;
    private Staff staff;
    public FormMain(Staff staff) {
        this.staff = staff;
        MAIN = this;
        initComponents();
    }

    private void toStaff(ActionEvent e) {
        // TODO add your code here
        if(staff.getStaffRank()<200){
            JOptionPane.showMessageDialog(this,"权限不足！");
        }
        StaffRegPanel staffRegPanel = new StaffRegPanel(staff);
        panelMain.removeAll();
        panelMain.add(staffRegPanel, BorderLayout.CENTER);
        validate();
    }

    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents  @formatter:off
        menuBar1 = new JMenuBar();
        menuStaff = new JMenuItem();
        toolBar1 = new JToolBar();
        btnStaff = new JButton();
        panelMain = new JPanel();

        //======== this ========
        setTitle("\u535a\u7269\u9986\u6587\u7269\u7ba1\u7406\u7cfb\u7edf");
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        var contentPane = getContentPane();
        contentPane.setLayout(new BorderLayout());

        //======== menuBar1 ========
        {

            //---- menuStaff ----
            menuStaff.setText("\u5458\u5de5\u7ba1\u7406");
            menuStaff.addActionListener(e -> toStaff(e));
            menuBar1.add(menuStaff);
        }
        setJMenuBar(menuBar1);

        //======== toolBar1 ========
        {
            toolBar1.setBorderPainted(false);

            //---- btnStaff ----
            btnStaff.setText("\u5458\u5de5\u7ba1\u7406");
            btnStaff.addActionListener(e -> toStaff(e));
            toolBar1.add(btnStaff);
        }
        contentPane.add(toolBar1, BorderLayout.NORTH);

        //======== panelMain ========
        {
            panelMain.setLayout(new BorderLayout());
        }
        contentPane.add(panelMain, BorderLayout.CENTER);
        setSize(800, 600);
        setLocationRelativeTo(null);
        // JFormDesigner - End of component initialization  //GEN-END:initComponents  @formatter:on
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables  @formatter:off
    private JMenuBar menuBar1;
    private JMenuItem menuStaff;
    private JToolBar toolBar1;
    private JButton btnStaff;
    private JPanel panelMain;
    // JFormDesigner - End of variables declaration  //GEN-END:variables  @formatter:on
}
